<?php

class User {
    public $userinfo = array();
    public $username = '';

    public function __construct($username){
        $this->username = $username;
    }

    public function getUserINfo(){
        require_once __DIR__.'/config.php';
        $conn = @mysql_connect($db_host,$db_user,$db_psw) or die('数据库连接失败.');
        mysql_select_db($db_name,$conn);
        mysql_query('SET NAMES'.$db_charset);
        $sql = "select * from iotek_user where username='{$this->username}'";
        $res = mysql_query($sql,$$conn);
        $userinfo = mysql_fetch_assoc($res,$conn);
        if($username){
            $this->userinfo = $userinfo;
        }
        mysql_close($conn);
        return $this->userinfo;
    }
}